package com.woniu.springbootrbac.service.impl;

import com.woniu.springbootrbac.dto.RoleDto;
import com.woniu.springbootrbac.entity.SysRole;
import com.woniu.springbootrbac.mapper.SysRoleMapper;
import com.woniu.springbootrbac.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private SysRoleMapper mapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(SysRole record) {
        return 0;
    }

    @Override
    public int insertSelective(SysRole record) {
        return 0;
    }

    @Override
    public SysRole selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(SysRole record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(SysRole record) {
        return 0;
    }

    @Override
    public List<SysRole> selAll() {
        return mapper.selAll();
    }

    @Override
    public List<Integer> selectRolesIdByUid(Long uid) {
        return mapper.selectRolesIdByUid(uid);
    }

    @Override
    @Transactional
    public int insertRole(RoleDto roleDto) {
        mapper.deleteByUid(roleDto.getUid());
        int i = mapper.insertRole(roleDto);
        return i;
    }
}
